#include<bits/stdc++.h>
using namespace std;
int N,L,R,ans=0;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&N,&L,&R);
	if(L==R){printf("%d",L%N);return 0;} 
	for(int i=0;i*N<=R;i++){
		if(N*i+N-1<L) continue;
		if(N*i+N-1>R) ans=max(ans,R-N*i);
		else ans=max(ans,N-1);
	}
	printf("%d",ans);
	return 0;
}
